from openpyxl import load_workbook

table_name = "code_id"
wb2 = load_workbook('%s.xlsx' % (table_name))
ws=wb2.get_sheet_names()
for row in wb2:
    inwhere = '('
    for cell in row:
        # 查询兑换码是否使用
        # selindentbuysql = 'SELECT * FROM %s WHERE id = (SELECT indent_id FROM redeem_code_use WHERE redeem_code_id = (SELECT id FROM redeem_code WHERE card_number = "%s"));' % (table_name, cell[0].value)
        # selredeemcodeusersql = 'SELECT * FROM redeem_code_use WHERE redeem_code_id = (SELECT id FROM redeem_code WHERE card_number = "%s");' % (cell[0].value)

        inwhere += str(cell[0].value) + ', '

    inwherestr = inwhere[:-2] + ')'

    selredeemcode = 'SELECT * FROM redeem_code_use WHERE redeem_code_id in %s;' % (inwherestr)
    print(selredeemcode)
print("over...")
